package com.shell.provider;

import com.shell.governor.modules.po.PubDate;
import com.shell.governor.modules.service.PubDateService;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PubDateProvider {
	@Autowired
	private PubDateService dateService;

	@RequestMapping(value = { "/date/isHoliday" }, method = {
			org.springframework.web.bind.annotation.RequestMethod.GET })
	public boolean isHoliday(@RequestParam("curDate") String curDate) {
		return this.dateService.isHoliday(curDate);
	}

	@RequestMapping(value = { "/date/getHoliday" }, method = {
			org.springframework.web.bind.annotation.RequestMethod.POST })
	public List<String> getHoliday(@RequestParam("startDate") String startDate,
			@RequestParam("endDate") String endDate) {
		List<PubDate> pubDates = this.dateService.queryHoliday(startDate, endDate);
		List<String> result = new ArrayList();
		for (PubDate pubDate : pubDates) {
			result.add(pubDate.getDateValue());
		}
		return result;
	}
}
